<!doctype html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <title>运维功能——数据加密</title>
    <script src="/webjars/miniui/boot.js" type="text/javascript"></script>
    <script src="/static/js/common/common.js" type="text/javascript"></script>
    <link href="/static/css/resource.css" rel="stylesheet" type="text/css" />
    <script src="/static/js/crypto/crypto-js.js"></script>
    <style type="text/css">
        body {
            margin:0;
            padding:0;
            border:0;
            width:100%;
            height:100%;
            overflow:hidden;
        }
    </style>
</head>
<body>
<!--撑满页面-->
<div class="mini-fit">
    <table class="form-table" align="center">
        <tr>
            <td style="width: 100px;text-align: right">账号密码:</td>
            <td>
                <input name="zhmm" id="zhmm" class="mini-textbox" style="width: 450px"  />
            </td>
            <td>
                <a class="mini-button" iconCls="fa-user" plain="true" onclick="zhmmClick()">加密</a>
            </td>
        </tr>
        <tr>
            <td style="width: 100px;text-align: right">数据库密码:</td>
            <td>
                <input name="sjkmm" id="sjkmm" class="mini-textbox" style="width: 450px" />
            </td>
            <td>
                <a class="mini-button" iconCls="fa-key" plain="true" onclick="sjkmmClick()">加密</a>
                <a class="mini-button" iconCls="fa-unlock-alt" plain="true" onclick="sjkmmClickCz()">解密</a>
            </td>
        </tr>
        <tr>
            <td style="width: 100px;text-align: right">身份证:</td>
            <td>
                <input name="sfz" id="sfz" class="mini-textbox" style="width: 450px" />
            </td>
            <td>
                <a class="mini-button" iconCls="fa-id-card" plain="true" onclick="sfzClick()">加密</a>
                <a class="mini-button" iconCls="fa-unlock-alt   " plain="true" onclick="sfzClickCz()">解密</a>
            </td>
        </tr>
        <tr>
            <td style="width: 100px;text-align: right">返回内容:</td>
            <td>
                <input class="mini-textarea" id="returnContent" name="returnContent" style="width: 450px;height:200px" emptyText="返回内容。。。"/>
            </td>
        </tr>
    </table>
</div>
<script type="text/javascript">
    mini.parse();

    //账号密码获取加密
    function zhmmClick(){
        encryptionFunction(getAesString(mini.get("zhmm").getValue()), 1);
    }

    //数据库密码获取加密
    function sjkmmClick(){
        encryptionFunction(mini.get("sjkmm").getValue(), 2);
    }

    //数据库密码解密
    function sjkmmClickCz(){
        encryptionFunction(mini.get("sjkmm").getValue(), 21);
    }

    //身份证获取加密
    function sfzClick(){
        encryptionFunction(mini.get("sfz").getValue(), 3);
    }

    //身份证重置解密
    function sfzClickCz(){
        encryptionFunction(mini.get("sfz").getValue(), 31);
    }

    /**
     * 加密
     * @param str 加密内容
     * @param type 1.账号；2.数据库；3.身份证
     */
    function encryptionFunction(str,type){
        var data = {
            content: str,
            type: type
        };
        $.ajax({
            url: '/azbj/maintenance/dataEncryption',
            data: {data: mini.encode(data)},
            type: "POST",
            success: function (res) {
                if(res.code===1){
                    mini.get("returnContent").setValue(res.data);
                }
            }
        });
    }

</script>
</body>
</html>